<?php 
		session_start(); 
		include "function/libfunc.php";
 			if (!empty($_SESSION['username']) && !empty($_SESSION['password'])) { 
		  	$link="Kategori";
		  	include 'themes/head2.php';
			include 'themes/heading.php';
?>

                    <!-- Build page from here: -->

                    <div class="row-fluid">

                         <div class="span12">
                            
                            <div class="box">

                                <div class="title">

                                    <h4>
                                        <span class="icon16 icomoon-icon-equalizer-2"></span>
                                        <span><?php echo $link?> | <a href="tambahkategori.php">Tambah Kategori</a></span>
                                    </h4>
                                    <a href="#" class="minimize">Minimize</a>
                                </div>
                                <div class="content noPad">
                                    <table class="responsive table table-bordered">
                                        <thead>
                                        <?php
                                        $link = koneksi_db();
                                        $sql = "SELECT * FROM kategori ORDER BY namakategori ASC";
                                        $hasil = mysql_query($sql,$link) or exit("Error query: <b>".$sql."</b>.");
										?>
                                          <tr>
                                            <th width="15%">Id Kategori</th>
                                            <th width="25%">Nama</th>
                                            <th width="40%">Deskripsi</th>
                                            <th width="20%">Menu</th>
                                          </tr>
                                        </thead>
                                        <tbody>
                                          <tr class="record">
                                          <?php
                                          while($data = mysql_fetch_assoc($hasil)){
										  ?>
                                            <td><?php echo $data['idkategori']; ?></td>
                                            <td><?php echo $data['namakategori']; ?></td>
                                            <td><?php echo $data['deskripsi']; ?></td>
                                            <td>
                                                <div class="controls center">
                                                    <a href="ubahkategori.php?id=<?php echo $data['idkategori']; ?>" title="Edit task" class="tip2"><span class="icon12 icomoon-icon-pencil"></span></a>
                                                   <?php echo '<a href="#" id="'.$data['idkategori'].'" class="tip" title="Klik disini untuk menghapus data!"><span class="icon12 icomoon-icon-remove"></span></a>'; ?>
                                                </div>
                                            </td>
                                          </tr>
                                          <?php 
										  }
										  ?>
                                        </tbody>
                                    </table>
<script type="text/javascript">
$(function() {


$(".tip").click(function(){

//Save the link in a variable called element
var element = $(this);

//Find the id of the link that was clicked
var del_id = element.attr("id");

//Built a url to send
var info = 'id=' + del_id;
 if(confirm("Apakah anda yakin untuk menghapus data ini?"))
		  {
 $.ajax({
   type: "GET",
   url: "function/deletekategori.php",
   data: info,
   success: function(){
   
   }
 });
         $(this).parents(".record").animate({ backgroundColor: "#fbc7c7" }, "fast")
		.animate({ opacity: "hide" }, "slow");

 }

return false;

});

});
</script>
                                </div>

                            </div><!-- End .box -->

                        </div><!-- End .span6 -->

                    </div><!-- End .row-fluid -->
                        
					
<?php
include 'themes/footer.php';
}else {
echo "<script language='javascript'>window.location = '../admin/'</script>";
}
?>
